/**
 * @file   String.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2014-04-19
 * @brief  DON data type object: String
 *
 * Copyright 2014  Djuro Drljaca (djurodrljaca@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DON_CORE_DATATYPES_STRING_H
#define DON_CORE_DATATYPES_STRING_H

#include <DON/Core/DataType/AbstractDataType.h>

namespace DON
{
namespace Core
{
namespace DataType
{

/**
 * @brief The String class
 */
class LIBDONQT4CORESHARED_EXPORT String : public AbstractDataType
{
public:
    /**
     * @brief Constructor
     */
    String();

    /**
     * @brief Copy constructor
     * @param other Object to be copied
     */
    String(const String &other);

    /**
     * @brief Destructor
     */
    ~String();

    /**
     * @brief Assignment operator
     * @param other Object to be copied
     * @return This object
     */
    String & operator=(const String &other);

    /**
     * @brief Clone the object
     * @return Cloned object
     */
    AbstractDataType * clone() const;

    /**
     * @brief Get data type
     * @return Data type
     */
    DataType getDataType() const;

    /**
     * @brief Get value
     * @return Value
     */
    QString getValue() const;

    /**
     * @brief Set value
     * @param value New value
     */
    void setValue(const QString &value);

    /**
     * @brief Import value from binary representation
     * @param data Binary data
     * @param startIndex Start index of the value data
     * @param[out] size Size in bytes of the imported value
     * @retval true Success
     * @retval false Error
     */
    bool fromBinary(const QByteArray &data, const int startIndex = 0, int *size = 0);

    /**
     * @brief Export value to binary representation
     * @return Binary data
     */
    QByteArray toBinary() const;

    /**
     * @brief Cast AbstractDataType instance to a String instance
     * @param[in] instance AbstractDataType instance
     * @return String instance
     * @retval NULL Error
     */
    static String * fromAbstractDataType(AbstractDataType *instance);

private:
    class Private;
    Private * const d;
};

}
}
}

#endif // DON_CORE_DATATYPES_STRING_H
